package cn.quevo.cube.provide.define.service.impl;

import cn.quevo.common.entity.PageResult;
import cn.quevo.cube.provide.define.dao.CubeModelColumnDao;
import cn.quevo.cube.provide.define.entity.dto.CubeColumnDto;
import cn.quevo.cube.provide.define.entity.query.CubeModelColumnQuery;
import cn.quevo.cube.provide.define.service.CubeModelColumnService;
import cn.quevo.cube.provide.define.validate.ColumnTypeValidateFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 模型字段 Service接口实现
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/12/11 14:57:15
 * @Copyright 东方浩星（北京）传媒科技有限公司版权所有.All Rights Reserved.
 */
@Service("cubeModelColumnService")
@Transactional(transactionManager = "transactionManager", rollbackFor = {Exception.class})
public class CubeModelColumnServiceImpl implements CubeModelColumnService {
    @Resource(name = "cubeModelColumnDao")
    private CubeModelColumnDao cubeModelColumnDao;

    @Override
    public Map<String, Object> getSinge(CubeModelColumnQuery cubeModelColumnQuery) {
        return this.cubeModelColumnDao.getSinge(cubeModelColumnQuery);
    }

    @Override
    public Integer create(CubeColumnDto cubeModelColumn) {
        cubeModelColumn.validateCreate();
        ColumnTypeValidateFactory.validate(cubeModelColumn);
        return this.cubeModelColumnDao.create(cubeModelColumn);
    }

    @Override
    public Integer update(CubeColumnDto cubeModelColumn) {
        cubeModelColumn.validateUpdate();
        return this.cubeModelColumnDao.update(cubeModelColumn);
    }

    @Override
    public PageResult<Map<String, Object>> getPage(CubeModelColumnQuery cubeModelColumnQuery) {
        return this.cubeModelColumnDao.getPage(cubeModelColumnQuery);
    }
}
